const {Model, DataTypes} = require('sequelize');
const sequelize = require('../config/db');

class GoodsTag extends Model {}
GoodsTag.init({
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true,
  },
  goods_id: {
    type: DataTypes.INTEGER,
    allowNull: false,
    references: {
      model: 'goods',
      key: 'id'
    }
  },
  tag_id: {
    type: DataTypes.INTEGER,
    allowNull: false,
    references: {
      model: 'tag',
      key: 'id'
    }
  }
},{
  sequelize,
  tableName: 'goods_tag',
  modelName: 'goods_tag',
  timestamps: false,
})

// 需要在associations.js中添加关联关系
// 这里只是提前声明，防止循环引用

module.exports = GoodsTag
